/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.araujogrosz.fractalcore;

import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;

/**
 *
 * @author renatogrosz@gmail.com
 */
public class DefaultMouseListener implements MouseWheelListener {

    private Zoonable zoonable;
    private Calcable calcable;
    private ImageDrawner imageDrawner;
    public DefaultMouseListener(Zoonable zoonable, Calcable calcable, ImageDrawner imageDrawner){
        this.zoonable = zoonable;
        this.calcable = calcable;
        this.imageDrawner = imageDrawner;
    }
    
     @Override
    public void mouseWheelMoved(MouseWheelEvent mwe) {
        //int x = mwe.getX() - WindowParam.WINDOW_TITLE_HEIGHT;
        int x = mwe.getX() - WindowParam.LEFT_BORDER;
        
        //int y = mwe.getY() - WindowParam.LEFT_BORDER;
        int y = mwe.getY() - WindowParam.WINDOW_TITLE_HEIGHT;
        if (mwe.getWheelRotation() > 0) {
            zoonable.zoom(x, y, WindowParam.WINDOW_ZOOM_OUT);
        } else {
            zoonable.zoom(x, y, WindowParam.WINDOW_ZOOM_IN);
        }
        calcable.calc(); 
        imageDrawner.drawImage();                
    }
    
}
